/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package quanlisinhvien.bll;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import quanlisinhvien.dal.KhoaDAO;
import quanlisinhvien.dto.KhoaDTO;

/**
 *
 * @author Marshmallow
 */
public class KhoaBLL {

    private KhoaDAO khoaDAO;

    public KhoaBLL() {
        this.khoaDAO = new KhoaDAO();
    }
    
    public List<KhoaDTO> LayDanhSachKhoa(){
        try{
            List<KhoaDTO> danhSach = new ArrayList<KhoaDTO>();
            ResultSet rs = this.khoaDAO.LayDanhSachKhoa();
            while(rs.next()){
                KhoaDTO khoa = new KhoaDTO();
                khoa.setMaKhoa(rs.getInt("maKhoa"));
                khoa.setTenKhoa(rs.getString("tenKhoa"));
                danhSach.add(khoa);
            }
            return danhSach;
        }
        catch (Exception ex){
            System.out.println("From KhoaBLL:" + ex.getMessage());
            return null;
        }
    }
        
}
